	$(function(){	
		var row = [];
		var shi=[];
		var qu = [];
		var jie =[];
		function getOption(selector,all){
			$(selector).combobox({
				valueField:'name',
				textField:'name',
				data:all,
				multiple:false,
				method:'get',
			})
		}
		
			$.getJSON("http://restapi.amap.com/v3/config/district?key=dee5f9b5711cf08774863388826de28f&subdistrict=4",function(datas){
				var allTmp =datas.districts[0];
				var all = allTmp.districts;
				for(var i = 0; i < all.length;i++){
					row[i]=all[i];
				}
				getOption("#sheng",all);
				getOption("#sheng1",all);
				getOption("#sheng2",all);
			})
			
		
		$("#sheng").combobox({
			onChange:function shengs1(){
				resets("#qu","#jie");
				shengs("#sheng","#shi")
			}
		});
		$("#sheng1").combobox({
			onChange:function shengs1(){
				resets("#qu1","#jie1");
				shengs("#sheng1","#shi1")
			}
		});
		$("#sheng2").combobox({
			onChange:function shengs1(){
				resets("#qu2","#jie2");
				shengs("#sheng2","#shi2")
			}
		});
		function resets(selector,selectors){
			$(selector).combobox("reset");
			$(selectors).combobox("reset");
		}
		function shengs(selector,selectors,p){
			var address= $(selector).combobox("getValue");
			for(var i = 0; i < row.length;i++){
				if(address == row[i].name){
					shi[0] = row[i].districts;
					getOption(selectors,row[i].districts);
				}
			}
		}
		$("#shi").combobox({
			onChange:function shis1(){
				resett("#jie");
				shis("#shi","#qu")
			}
		});
		$("#shi1").combobox({
			onChange:function shis1(){
				resett("#jie1");
				shis("#shi1","#qu1")
			}
		});
		function resett(selector){
			$(selector).combobox("reset");
		}
		function shis(selector,selectors){
				var address=$(selector).combobox("getValue"); 
				for(var j = 0; j <shi[0].length;j++){
					if(address == shi[0][j].name){
						getOption(selectors,shi[0][j].districts);
						qu[0] = shi[0][j].districts;
					}
				}
			}
		$("#qu").combobox({
			onChange:function qus1(){
				qus("#qu","#jie")
			}
		});
		$("#qu1").combobox({
			onChange:function qus1(){
				qus("#qu1","#jie1")
			}
		});
		function qus(selector,selectors){
				var address=$(selector).combobox("getValue");  
				for(var k = 0; k <qu[0].length;k++){
					if(address == qu[0][k].name){
						getOption(selectors,qu[0][k].districts);
						jie[0] = qu[0][k].districts;
					}
				}
		}
});